<template>
  <div class="mineBox">
    <info v-if="isLogin"></info>
    <van-tabs type="card" v-model="active" v-else>
      <van-tab title="登录">
        <login></login>
      </van-tab>
      <van-tab title="注册">
        <register @setActive="setActive"></register>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import login from "../components/mine/LoginView.vue";
import register from "@/components/mine/RegisterView.vue";
import info from "@/components/mine/InfoView.vue";
export default {
  data() {
    return {
      active: 0, //数据
      isLogin: false, //是否登录
    };
  },
  created() {
    this.isLogin = window.localStorage.getItem("token") ? true : false;
  },
  methods: {
    setActive(index) {
      //修改数据的方法
      this.active = index;
    },
  },
  components: {
    login,
    register,
    info,
  },
};
</script>

<style lang="scss" scoped>
.mineBox {
  // padding-top: 100px;
  background: #fff;
}
</style>
